<?php

use App\Models\Advert;
use App\Models\Artcat;
use App\Models\Course;
use App\Models\CoursePackage;
use App\Models\LmColumn;
use App\Models\LmSubject;
use App\Models\Organize;
use App\Models\Provinces;
use App\Models\Teacher;
use App\Models\UsersCourse;

//用户默认头像
function getUsersDefaultAvatar($avatar)
{
    if (empty($avatar)) {
        $avatar = "/home/img/Avatar.png";
    }
    return $avatar;
}

//课程默认图片
function getCourseDefaultAvatar($thumb)
{
    if (empty($thumb)) {
        $thumb = "/home/adver/default.gif";
    }
    return $thumb;
}

function getUrlQuery($url)
{
    $refer_url = parse_url($url);
    $params = $refer_url['query'];
    $arr = array();
    if (!empty($params)) {
        $paramsArr = explode('&', $params);
        foreach ($paramsArr as $k => $v) {
            $a = explode('=', $v);
            $arr[$a[0]] = $a[1];
        }
    }
    return $arr;
}

/**
 * object 转 array
 */
function object_to_array($obj)
{
    $_arr = is_object($obj) ? get_object_vars($obj) : $obj;
    foreach ($_arr as $key => $val) {
        $val = (is_array($val)) || is_object($val) ? object_to_array($val) : $val;
        $arr[$key] = $val;
    }
    return $arr;
}
